home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1998 January / PC Answers Issue 49 Cover CD January 1998.iso / Apps / Director / DATA.Z / Learning Director.dcr / Internal_11_MS_Compile.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  9.6 KB  |  279 lines

  1. on CompileScore
  2.   set lessonList to [:]
  3.   set numLabels to the number of lines in the labelList
  4.   repeat with labelNum = 1 to numLabels - 1
  5.     set labelName to line labelNum of the labelList
  6.     set firstCharOfLabel to char 1 of labelName
  7.     if firstCharOfLabel = "L" then
  8.       set pos to offset("-", labelName)
  9.       set lessonNum to value(chars(labelName, 2, pos - 1))
  10.       if integerp(lessonNum) then
  11.         set lessonData to getaProp(lessonList, lessonNum)
  12.         if voidp(lessonData) then
  13.           set lessonData to [#firstLabel: labelName, #tryItFrame: 0]
  14.           setaProp(lessonList, lessonNum, lessonData)
  15.         end if
  16.       end if
  17.       next repeat
  18.     end if
  19.     if firstCharOfLabel = "T" then
  20.       set lessonNum to value(chars(labelName, 2, length(labelName)))
  21.       set lessonData to getaProp(lessonList, lessonNum)
  22.       setaProp(lessonData, #tryItFrame, label(labelName))
  23.     end if
  24.   end repeat
  25.   set supportList to [:]
  26.   addProp(supportList, "Title#richText", #richText)
  27.   addProp(supportList, "Title#field", #field)
  28.   addProp(supportList, "Steps#field", #field)
  29.   set numLessons to count(lessonList)
  30.   repeat with index = 1 to numLessons
  31.     set lessonNum to getPropAt(lessonList, index)
  32.     set lessonPrefix to "L" & string(lessonNum) & "-"
  33.     put "Verifying data for lesson" && string(lessonNum)
  34.     set numSupports to count(supportList)
  35.     repeat with supportIndex = 1 to numSupports
  36.       set memType to getAt(supportList, supportIndex)
  37.       set memName to lessonPrefix & getPropAt(supportList, supportIndex)
  38.       if not DoesMemberExist(memName, memType) then
  39.         halt()
  40.       end if
  41.     end repeat
  42.   end repeat
  43.   set numLessons to count(lessonList)
  44.   set lessonNameList to []
  45.   repeat with index = 1 to numLessons
  46.     set lessonNum to getPropAt(lessonList, index)
  47.     set lessonPrefix to "L" & string(lessonNum) & "-"
  48.     put "Building data for lesson" && string(lessonNum)
  49.     set stepsList to []
  50.     set memName to lessonPrefix & "Title#field"
  51.     set lessonName to stripWhiteSpace(the text of member memName, #both)
  52.     append(lessonNameList, the text of member memName)
  53.   end repeat
  54.   putlist(lessonNameList, "@LessonListNames#field", "AuthorData")
  55.   putlist(lessonList, "@LessonList#field", "AuthorData")
  56.   put "Recording Score"
  57.   set saveFrame to the frame
  58.   set lastFrame to the lastFrame
  59.   SaveAndClearPuppets()
  60.   set the updateLock to 1
  61.   beginRecording()
  62.   repeat with index = 1 to numLessons
  63.     set lessonNum to getPropAt(lessonList, index)
  64.     set lessonPrefix to "L" & string(lessonNum) & "-"
  65.     put "Recording data for lesson" && string(lessonNum)
  66.     set lessonData to getaProp(lessonList, lessonNum)
  67.     set labelName to getaProp(lessonData, #firstLabel)
  68.     set hasTryIt to getaProp(lessonData, #tryItFrame) > 0
  69.     if hasTryIt then
  70.       set navBarName to "NavBar2"
  71.     else
  72.       set navBarName to "NavBar1"
  73.     end if
  74.     set frameNum to label(labelName)
  75.     go(frameNum)
  76.     Record_SS_LessonInit(navBarName)
  77.     set stepNum to 1
  78.     set possibleTN to "T" & string(lessonNum)
  79.     set possibleXN to "X" & string(lessonNum)
  80.     set possibleLN to lessonPrefix & string(stepNum)
  81.     repeat while 1
  82.       set labelName to the frameLabel
  83.       if (labelName = 0) or (labelName = "W1") or (labelName = "W2") or (labelName = "K1") or (labelName = "K2") then
  84.         if isFrameEmpty() then
  85.           put "ERROR: Empty frame or missing required label"
  86.           halt()
  87.         else
  88.           Record_SS_LessonBody(navBarName)
  89.         end if
  90.         next repeat
  91.       end if
  92.       if labelName = possibleLN then
  93.         Record_SS_LessonStep(navBarName)
  94.         set stepNum to stepNum + 1
  95.         set possibleLN to lessonPrefix & string(stepNum)
  96.         next repeat
  97.       end if
  98.       if labelName = possibleTN then
  99.         go(label(labelName) - 1)
  100.         Record_SS_LessonEnd("NavBar2")
  101.         Record_SS_TryIt()
  102.         exit repeat
  103.         next repeat
  104.       end if
  105.       if labelName = possibleXN then
  106.         Record_SS_ExitLesson()
  107.         go(label(labelName) - 1)
  108.         Record_SS_LessonEnd("NavBar1")
  109.         exit repeat
  110.       end if
  111.     end repeat
  112.   end repeat
  113.   endRecording()
  114.   RestorePuppets()
  115.   go(saveFrame)
  116.   set the updateLock to 0
  117. end
  118.  
  119. on DoesMemberExist memName, memType
  120.   set memNum to the number of member memName
  121.   if memNum <= 0 then
  122.     put "Required #" & string(memType) && "member" && QUOTE & memName & QUOTE && "missing."
  123.     return 0
  124.   else
  125.     if the type of member memNum <> memType then
  126.       put "Required member " & QUOTE & memName & QUOTE & ", " & string(member memNum) & ", is not of type #" & string(memType) & "."
  127.       return 0
  128.     end if
  129.   end if
  130.   return 1
  131. end
  132.  
  133. on Record_SS_LessonInit navBarName
  134.   set the frameScript to member "SS_LessonInit"
  135.   Record_StdLessonSprites()
  136.   set channelNum to 46
  137.   set memberNum to the number of member navBarName
  138.   set the castNum of sprite channelNum to memberNum
  139.   set the rect of sprite channelNum to rect(0, 356, 0 + 320, 356 + 12)
  140.   updateFrame()
  141. end
  142.  
  143. on Record_SS_LessonStep navBarName
  144.   set the frameScript to member "SS_LessonStep"
  145.   Record_StdLessonSprites()
  146.   set channelNum to 46
  147.   set memberNum to the number of member navBarName
  148.   set the castNum of sprite channelNum to memberNum
  149.   set the rect of sprite channelNum to rect(0, 356, 0 + 320, 356 + 12)
  150.   updateFrame()
  151. end
  152.  
  153. on Record_SS_LessonBody navBarName
  154.   set labelName to the frameLabel
  155.   case the frameLabel of
  156.     "W1":
  157.       set the frameScript to member "SS_LessonBody(W1)"
  158.     "W2":
  159.       set the frameScript to member "SS_LessonBody(W2)"
  160.     "K1":
  161.       set the frameScript to member "SS_LessonBody(K1)"
  162.     "K2":
  163.       set the frameScript to member "SS_LessonBody(K2)"
  164.     otherwise:
  165.       set the frameScript to member "SS_LessonBody"
  166.   end case
  167.   Record_StdLessonSprites()
  168.   set channelNum to 46
  169.   set memberNum to the number of member navBarName
  170.   set the castNum of sprite channelNum to memberNum
  171.   set the rect of sprite channelNum to rect(0, 356, 0 + 320, 356 + 12)
  172.   updateFrame()
  173. end
  174.  
  175. on Record_SS_LessonEnd navBarName
  176.   set the frameScript to member "SS_LessonEnd"
  177.   set channelNum to 46
  178.   set memberNum to the number of member navBarName
  179.   set the castNum of sprite channelNum to memberNum
  180.   set the rect of sprite channelNum to rect(0, 356, 0 + 320, 356 + 12)
  181.   Record_StdLessonSprites()
  182.   updateFrame()
  183. end
  184.  
  185. on Record_SS_TryIt
  186.   set the frameScript to member "SS_TryIt"
  187.   Record_StdLessonSprites()
  188.   set channelNum to 46
  189.   set memberNum to the number of member "NavBar1"
  190.   set the castNum of sprite channelNum to memberNum
  191.   set the rect of sprite channelNum to rect(0, 356, 0 + 320, 356 + 12)
  192.   updateFrame()
  193. end
  194.  
  195. on Record_SS_ExitLesson
  196.   set the frameScript to member "SS_ExitLesson"
  197.   Record_StdLessonSprites()
  198.   set channelNum to 46
  199.   set memberNum to the number of member "NavBar1"
  200.   set the castNum of sprite channelNum to memberNum
  201.   set the rect of sprite channelNum to rect(0, 356, 0 + 320, 356 + 12)
  202.   updateFrame()
  203. end
  204.  
  205. on Record_StdLessonSprites
  206.   set channelNum to 2
  207.   set memberNum to the number of member "AnimBackground"
  208.   set the castNum of sprite channelNum to memberNum
  209.   set the rect of sprite channelNum to the rect of member memberNum
  210.   set the loc of sprite channelNum to point(0, 0)
  211.   set channelNum to 36
  212.   set memberNum to the number of member "LessonStepsFrame"
  213.   set the castNum of sprite channelNum to memberNum
  214.   set the rect of sprite channelNum to rect(0, 235, 320, 235 + 122)
  215.   set channelNum to 39
  216.   set memberNum to the number of member "TitleStandIn#richText"
  217.   set the castNum of sprite channelNum to memberNum
  218.   set the rect of sprite channelNum to rect(6, 243, 6 + 308, 243 + 16)
  219.   set the ink of sprite channelNum to 36
  220.   set channelNum to 37
  221.   set memberNum to the number of member "TitleStandInShadow#richText"
  222.   set the castNum of sprite channelNum to memberNum
  223.   set the rect of sprite channelNum to rect(7, 244, 7 + 308, 244 + 16)
  224.   set the ink of sprite channelNum to 36
  225.   set channelNum to 38
  226.   set memberNum to the number of member "CurrentLessonSteps#field"
  227.   set the castNum of sprite channelNum to memberNum
  228.   set the rect of sprite channelNum to rect(3, 267, 3 + 297, 267 + 84)
  229.   set channelNum to 40
  230.   set memberNum to the number of member "vscrollbar"
  231.   set the castNum of sprite channelNum to memberNum
  232.   set the rect of sprite channelNum to rect(307, 279, 307 + 11, 279 + 64)
  233.   set channelNum to 41
  234.   set memberNum to the number of member "Thumb"
  235.   set the castNum of sprite channelNum to memberNum
  236.   set the rect of sprite channelNum to rect(307, 280, 307 + 11, 280 + 9)
  237.   set channelNum to 42
  238.   set memberNum to the number of member "UpArrow_out"
  239.   set the castNum of sprite channelNum to memberNum
  240.   set the rect of sprite channelNum to rect(307, 267, 307 + 11, 267 + 12)
  241.   set channelNum to 43
  242.   set memberNum to the number of member "DownArrow_out"
  243.   set the castNum of sprite channelNum to memberNum
  244.   set the rect of sprite channelNum to rect(307, 343, 307 + 11, 343 + 12)
  245. end
  246.  
  247. on FixScore
  248.   put "Fixing Score"
  249.   set saveFrame to the frame
  250.   set lastFrame to the lastFrame
  251.   go(1)
  252.   SaveAndClearPuppets()
  253.   set the updateLock to 1
  254.   beginRecording()
  255.   repeat with frameNum = 1 to lastFrame
  256.     if the frameScript = the number of member "SS_LessonBody(W1)" then
  257.       put "W1 at" && frameNum
  258.       set the frameLabel to "W1"
  259.     end if
  260.     if the frameScript = the number of member "SS_LessonBody(W2)" then
  261.       put "W2 at" && frameNum
  262.       set the frameLabel to "W2"
  263.     end if
  264.     if the frameScript = the number of member "SS_LessonBody(K1)" then
  265.       put "K1 at" && frameNum
  266.       set the frameLabel to "K1"
  267.     end if
  268.     if the frameScript = the number of member "SS_LessonBody(K2)" then
  269.       put "K2 at" && frameNum
  270.       set the frameLabel to "K2"
  271.     end if
  272.     updateFrame()
  273.   end repeat
  274.   endRecording()
  275.   RestorePuppets()
  276.   go(saveFrame)
  277.   set the updateLock to 0
  278. end
  279.